﻿using UnityEngine;

namespace TC
{
    [Menu("Function/CreateCube")]
    public class CreateCube : FunctionNode
    {
        public ValueInput<Vector3> posIn;
        public ValueInput<Vector3> rotateIn;
        public ValueInput<Vector3> scaleIn;

        public override void OnCreate()
        {
            base.OnCreate();

            posIn = this.AddValueInPort<Vector3>("pos");
            rotateIn = this.AddValueInPort<Vector3>("rotate");
            scaleIn = this.AddValueInPort<Vector3>("scale");
        }

        public override void Execute(Dispatcher chain)
        {
            base.Execute(chain);

            GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);
            go.transform.position = posIn.Value;
            go.transform.localRotation = Quaternion.Euler(rotateIn.Value);
            go.transform.localScale = scaleIn.Value;

            chain.Call(flowOut);
        }
    }
}
